<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>Document</title>
</head>

<body>
  <ul>
    <li>我是列表项1</li>
    <li class="li2">我是列表项2</li>
    <li>我是列表项3</li>
  </ul>
  <script>
    var li2 = document.querySelector('.li2');
    // 上一个兄弟
    console.log(li2.previousElementSibling);
    // 下一个兄弟
    console.log(li2.nextElementSibling);



  </script>
</body>

</html>